﻿<!doctype html>
 <html >
 <head>
   <meta charset="UTF-8">
   <link rel="stylesheet" href="/css/common.css">
   <link rel="stylesheet" href="/css/main.css">
   <script type="text/javascript" src="/js/jquery.min.js"></script>
   <script type="text/javascript" src="/js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="/js/common.js"></script>
</head>

<body>
  <div id="forms" class="mt10">
        <div class="box">
          <div class="box_border">
            <div class="box_top"><b class="pl15">出差申请</b></div>
            <div class="box_center">
              <form id="form" class="jqtransform">
               <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                   <tr>
                       <td class="td_right">姓名：</td>
                       <td class="">
                           <input style="width: 40px; background-color: #EEEEEE;" readonly type="text" name="realName" value="${user.realName}">
                       </td>
                   </tr>
                   <tr>
                       <td class="td_right">部门：</td>
                       <td class="">
                           <select id="pp" style="width: 66px; background-color: #EEEEEE;" disabled="disabled">
                               <#list dept as d>
                                   <option <#if d.deptId == user.deptId>
                                       selected
                                   </#if> value="${d.deptId}">${d.deptName}</option>
                               </#list>
                           </select>

                       </td>
                   </tr>
                   <tr>
                      <td class="td_right">出差时间：</td>
                      <td>
                          <input id="start" type="date" name="startBusiness" class="input-text lh30" size="40">
                          to
                          <input id="end" type="date" name="endBusiness" class="input-text lh30" size="40">
                      </td>
                   </tr>
                    <tr>
                      <td class="td_right">出差地点：</td>
                      <td>
                          <input onchange="gai()" id="yuy" type="text" name="siteBusiness" class="input-text lh30" size="40">
                      </td>
                    </tr>
                    <tr>
                      <td class="td_right">交通工具：</td>
                      <td>
                          <input onchange="gai1()" id="yuy1" type="text" name="volcation" class="input-text lh30" size="40">
                      </td>
                    </tr>
                    <tr>
                      <td class="td_right">出差事由：</td>
                      <td>
                          <textarea onchange="gai2()" id="yuy2" name="causeBusiness" class="input-text lh30"></textarea>
                      </td>
                    </tr>
                    <tr>
                      <td class="td_right">工作任务：</td>
                      <td>
                          <textarea onchange="gai3()" id="yuy3" name="workTask" class="input-text lh30"></textarea>
                      </td>
                    </tr>
                    <tr>
                      <td class="td_right">借款金额：</td>
                      <td>
                          <input id="num" type="number" name="workMoney" class="input-text lh30" size="40">
                      </td>
                    </tr>

                    <tr>
                      <td class="td_right">下一步审批人：</td>
                      <td>
                          <select id="userid" name="userId" class="input-text lh30">
                              <option value="-1">---请选择---</option>
                              <#list listuser as luser>
                                  <option value="${luser.userId}">${luser.realName}</option>
                              </#list>
                          </select>
                      </td>
                    </tr>
                     <tr>
                       <td class="td_right">&nbsp;</td>
                       <td class="">
                         <input type="button" id="chuchai" class="btn btn82 btn_save2" value="确定">
                        <input type="button" class="btn btn82 btn_res" onclick="location.href='javascript:history.go(-1)'" value="返回">
                       </td>
                     </tr>
               </table>
               </form>
            </div>
          </div>
        </div>
     </div>
   </div>
<script>

    //输入框必须输汉字
    function gai(){
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy").value)){
            alert("您必须输入汉字")
            return;
        }
    }
    //输入框必须输汉字
    function gai1(){
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy1").value)){
            alert("您必须输入汉字")
            return;
        }
    }
    //输入框必须输汉字
    function gai2(){
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy2").value)){
            alert("您必须输入汉字")
            return;
        }
    }
    //输入框必须输汉字
    function gai3(){
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy3").value)){
            alert("您必须输入汉字")
            return;
        }
    }
    //比较时间
    $("#end").change(function () {
        var start = $("#start").val().split("-");
        var starts = start[0] + start[1] + start[2];
        var end = $("#end").val().split("-");
        var ends = end[0] + end[1] + end[2];
        if (parseInt(ends) < parseInt(starts)){
            alert("结束时间不能大于开始时间");
            location.href = "/resource/renshi/demo2/list";
        }
    });

    $("#chuchai").click(function () {
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy").value)){
            alert("出差地点必须为汉字，快改正吧")
            return;
        }
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy1").value)){
            alert("交通工具必须为汉字，快改正吧")
            return;
        }
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy2").value)){
            alert("出差事由必须为汉字，快改正吧")
            return;
        }
        if(!/^[\u4e00-\u9fa5]+$/gi.test(document.getElementById("yuy3").value)){
            alert("工作任务必须为汉字，快改正吧")
            return;
        }
        var num = $("#num").val();
        if (parseInt(num) < 0){
            alert("借款金额输入不合法");
            return;
        }
        var userid = $("#userid").val();
        if (parseInt(userid) <= 0){
            alert("您还没选择审核人，请选择审核人后再确定");
            return;
        }
        $("#pp").removeAttr("disabled");
        $.post(
            "/resource/add-bus"
            ,$("#form").serialize()
            ,function (result) {
                if (result.code == 0){
                    alert("申请出差已送达，等待审核，请耐心等待");
                    location.href = "/resource/renshi/demo2/list";
                } else {
                    alert(result.msg);
                }
            }
            ,"json"
        );
    });
</script>
</body>
</html>